package com.hw.paltfrom.service.system;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hw.paltfrom.mapper.HwExceptionLogMapper;
import com.hw.paltfrom.pojo.HwExceptionLog;
import com.hw.paltfrom.rescode.HWSystemCode;
import com.hw.paltfrom.utils.ResponeResultUtil;
import com.hw.paltfrom.vo.ExceptionLogVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 异常日志处理
 * 崔孟超
 * 2019年11月6日15:41:47
 */
@Service
public class ExceptionLogServer {
    @Autowired
    private HwExceptionLogMapper hwExceptionLogMapper;

    public Map<String, Object> queryAllList(ExceptionLogVo vo) {

        Wrapper<HwExceptionLog> wrapper = new EntityWrapper<HwExceptionLog>();

        if (StringUtils.isNotBlank(vo.getBeginFTime())&&StringUtils.isNotBlank(vo.getFinishFTime())){
             //获的当前的时间戳
            String beginFTime = vo.getBeginFTime();
            String finishFTime = vo.getFinishFTime();
            // 设置时间格式
            //   SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            // 将之间戳转换成Date类型
            long beginlong = new Long(beginFTime);
            long finishlong = new Long(finishFTime);
            wrapper.and().between("F_Time", new Date(beginlong), new Date(finishlong));
           }
        PageHelper.startPage(vo.getPageNum(), vo.getPageSize());
        List<HwExceptionLog> HwExceptionLogList = hwExceptionLogMapper.selectList(wrapper);
        PageInfo<HwExceptionLog> info = new PageInfo<>(HwExceptionLogList);
        return ResponeResultUtil.successNotice(HWSystemCode.SUCCESS, info);
    }
}
